/**
 * 
 */
package evolution;

import java.util.ArrayList;

/**
 * @author vtkhanh
 * 
 */
public class Generation {
    private ArrayList<Individual> mIndividuals = new ArrayList<Individual>();

    public void addIndividual(Individual individual) {
	mIndividuals.add(individual);
    }

    public ArrayList<Individual> getIndividuals() {
	return mIndividuals;
    }

    public void setIndividuals(ArrayList<Individual> individuals) {
	mIndividuals = individuals;
    }

    public void removeIndividual(Individual choosen) {
	mIndividuals.remove(choosen);
    }

    public int getSize() {
	return mIndividuals.size();
    }

    public Individual getBestIndividual() {
	int min = Integer.MAX_VALUE;
	Individual best = null;
	for (Individual individual : mIndividuals) {
	    if (min > individual.getCost()) {
		min = individual.getCost();
		best = individual;
	    }
	}
	return best;
    }
}
